<?php if ( ! defined('ABS_PATH')) exit('ABS_PATH is not loaded. Direct access is not allowed.');

   class ItemStats extends DAO {

        private static $instance ;

        public static function newInstance() {
            if(!self::$instance instanceof self) {
                self::$instance = new self ;
            }
            return self::$instance ;
        }

        public function getTableName() { return DB_TABLE_PREFIX . 't_item_stats'; }

        public function increase($column, $id) {
           $this->conn->osc_dbExec('INSERT INTO %s (fk_i_item_id, dt_date, %3$s) VALUES (%d, \'%4$s\',1) ON DUPLICATE KEY UPDATE %3$s = %3$s + 1', $this->getTableName(), $id, $column, date('Y-m-d H:i:s')) ;
        }

        public function emptyRow($id) {
           $this->conn->osc_dbExec('INSERT INTO %s (fk_i_item_id, dt_date) VALUES (%d, \'%s\')', $this->getTableName(), $id, date('Y-m-d H:i:s')) ;
        }
    }

?>